/*

Mask_mandate paper code 10_26_2022

1-start by importing set of datasets 
2-choose the category we want to consider (each category represent switch type processed in python code)
3-Two used command for interrupted time serise (ITSA,XTITSA)
********************************ITSA
Not working with panel data the dataset must be collapsed then we will have only 17 weeks (4 weeks before mask+12 weeks after mask) for the whole US
then we return the shiffted week_from opening by 5 to get the origional week number -4,-3,-2..........17
set the panel variable to week as we do not have fips, finally run the itsa command 

********************************XTITSA
Working with panel data the dataset must be collapsed then we will have  17 weeks (4 weeks before mask+12 weeks after mask) for the each county in US
then we return the shiffted week_from opening by 5 to get the origional week number -4,-3,-2..........17
set the panel variable to fips week , run the xtitsa command without any varaiable to genarate _x0 variable (0 before week0, 1 after week0), finally run the xtitsa command with alla variable
******************************************
In this code we run the same code with different lag (0,1,2) means week0, week1, week2 to study the sensitivety of results to different lags
***************************************
Set of tables were genrated as statistical analysis and unadjusted mean 
*/

ssc install xtitsa
ssc install coefplot
ssc install outreg2
 estimates store trad_W_all_res_dummy
 outreg2 using myresult2_mask_inout16_weeks.doc, append ctitle(No_resident_mask_mandates_in)

clear

use "C:\Users\aalamer1\Desktop\final_4_10_region_updated_update_36998.dta"

use "C:\Users\aalamer1\Desktop\final_4_10_region_updated.dta"

drop if fips==2997
drop if fips==2998



 merge m:1 fips using "C:\Users\aalamer1\Desktop\risks_levels.dta"
 merge m:1 fips using "C:\Users\aalamer1\Desktop\risk_levels_CDC.dta"

 
 merge m:1 fips using "C:\Users\aalamer1\Desktop\All_dempgraphic_merged_fips_final_use_6_10.dta",  generate(_merge2)


 merge m:1 fips using "C:\Users\aalamer1\Desktop\UR_7_15.dta",generate(_merge3)
 
keep if _merge==3

keep if _merge2==3
keep if _merge3==3

 
keep if category=="A"
 g calender_week=week( mask_date)
 ***************************************************************************************Vaccine Processing 
 
 g vaccin_date= "3/29/2021" 


g vaccin_date2=date(vaccin_date,"MDY")


g delta_vaccin_in_fix=date2-vaccin_date2



gen week_from_itopn _7_fix =round(delta_vaccin_in_fix/7)

generate week_from_vaccin_7_5_fix= week_from_vaccin_7_fix+5


generate week_from_vaccin_7_5_2_fix = week_from_vaccin_7_5_fix if week_from_vaccin_7_5_fix >= 0 & week_from_vaccin_7_5_fix <= 18

 g calender_week=week( vaccin_date2)

 mean cases_per_100K if category=="A" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_A

  mean cases_per_100K if category=="D" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_D


   mean cases_per_100K if category=="C" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_C

ssc install coefplot 
 coefplot  (cat_A,recast(connected)  label(Mandate) mlcolor(black) mcolor(red ) msize(7-pt) msymbol(D ) lcolor(black))  (cat_C,recast(connected)  label(Recommended) mlcolor(black) mcolor(blue ) msize(7-pt) msymbol(S ) lcolor(black))  (cat_D,recast(connected)  label(No restriction) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(T ) lcolor(black)) ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean COVID-19 Incidence Rate per 100,000 Residents",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean COVID-19 Incidence Rate per 100,000 Residents ",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(gr1111)
 
 
 collapse (mean)  Avg_cases=cases_per_100K  , by(fips week_from_vaccin_7_5_2_fix calender_week  less_20_cat age_20_39_cat age_40_59_cat age_60_84_cat age_over_85_cat income_median  non_hispanic_latin_percent_cat hispanic_latin_percent_cat others_ethn_percent_cat white_only_percent_cat blk_african_amr_percent_cat other_races_percent_cat    )
 
 
.  g weeks= week_from_vaccin_7_5_2_fix-5

.  g calender_week_from_vaccin= calender_week+ weeks

 drop if weeks==-5
 drop if weeks==.

tsset fips weeks
. gen resid = Avg_cases - _s__Avg_cases_pred if e(sample)
actest resid, lags(17) robust
 
. xtitsa Avg_cases   i.calender_week_from_vaccin, single  trperiod(1) vce(robust) posttrend  replace corr(ar 9)


xtitsa Avg_cases  i.calender_week_from_vaccin  i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat, single  trperiod(1)   posttrend  replace corr(ar 9)
*******************************************************************************************8

 *****************************Collaps for ITSA command ( we will have 12 weeks for whole US)
 collapse (mean)  Avg_cases=cases_per_100K, by(week_from_opening_7_5_2_fix   )
 
  *****************************Collaps for ITSA command For risk levels (each level will have 17 obseravation )
  keep if (risk==3)
 collapse (mean)  Avg_cases=cases_per_100K, by(week_from_opening_7_5_2_fix  )
 
 
 *****************************************************Collaps for XTITSA command 
 ********* collaps without risk levels for B and C remove roboust 
 
 collapse (mean)  Avg_cases=cases_per_100K  , by(fips week_from_opening_7_5_2_fix calender_week  less_20_cat age_20_39_cat age_40_59_cat age_60_84_cat age_over_85_cat income_median  non_hispanic_latin_percent_cat hispanic_latin_percent_cat others_ethn_percent_cat white_only_percent_cat blk_african_amr_percent_cat other_races_percent_cat ur category )

*************Collaps with risks_levels
 replace risk=int(risk)
 collapse (mean)  Avg_cases=cases_per_100K  , by(fips week_from_opening_7_5_2_fix calender_week  risk less_20_cat age_20_39_cat age_40_59_cat age_60_84_cat age_over_85_cat income_median non_hispanic_latin_percent_cat hispanic_latin_percent_cat others_ethn_percent_cat white_only_percent_cat blk_african_amr_percent_cat other_races_percent_cat )

**. collapse (mean)  Avg_cases=cases_per_100K  , by(   category  income_median less_20 age_20_39 age_40_59 age_60_84 age_over_85 non_hispanic_latin_percent hispanic_latin_percent others_percent white_only_percent blk_african_amr_percent other_races_percent )

*****************collaps for expmentary tabel 
. collapse (mean)  Avg_cases=cases_per_100K  , by(   category  VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 non_hispanic_latin_percent hispanic_latin_percent others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent ur)

rename others_percent others_ethnicity_percent


codebook fips

.  g weeks= week_from_opening_7_5_2_fix-5

.  g calender_week_from_opening= calender_week+ weeks
 drop if weeks==-5
 drop if weeks==.

tsset fips weeks

******************************ITSA Command  for each category and each risk level 

.  g weeks= week_from_opening_7_5_2_fix-5
 drop if weeks==-5
 drop if weeks==.
 
tsset  weeks

****lag 0
itsa Avg_cases  , single  trperiod(0)  posttrend   replace

******lag 1
itsa Avg_cases , single  trperiod(1)  posttrend   replace

************lag 2
itsa Avg_cases  , single  trperiod(2)  posttrend   replace
************lag 3 
itsa Avg_cases  , single  trperiod(3)  posttrend   replace

************************Without any demographic data just change corr to groups A 14, B 4 , C 5 D 2
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(0) posttrend  replace vce(robust) corr(ar 15)


****************auto correlation test
. gen resid = Avg_cases - _s__Avg_cases_pred if e(sample)
actest resid, lags(17) robust
********************************************Panel Data without covariates
****lag0 
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(0)  posttrend  replace 

********8lag 1
xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(1) posttrend  replace 	corr(ar	2)
***************************Income+Races +Ethnicity+Age **********************ahange corr(ar 14) every time for different groups 0lag
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(0)  posttrend  replace

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat, single  trperiod(0)   vce(robust)  posttrend  replace corr(ar 4)

***************************Income+Races +Ethnicity+Age **********************ahange corr(ar 14) every time for different groups 1lag
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(1) vce(robust) posttrend  replace corr(ar 2)


xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat, single  trperiod(1)   posttrend  replace corr(ar 2)


***************************Income+Races +Ethnicity+Age **********************ahange corr(ar 14) every time for different groups 2lag
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(2) vce(robust) posttrend  replace


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat, single  trperiod(2)    posttrend  replace corr(ar 4)


***************************Income+Races +Ethnicity+Age **********************ahange corr(ar 14) every time for different groups 3lag
. xtitsa Avg_cases i.calender_week_from_opening  , single  trperiod(3) vce(robust) posttrend  replace


xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat, single  trperiod(3)   posttrend  replace corr(ar 4)




****************************************************Risk Levels  lag0
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 14)

***********************Low 
. xtitsa Avg_cases i.calender_week_from_opening   if risk==0, single  trperiod(0) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if risk==0, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 14)


***********************Mid  

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if risk==1, single  trperiod(0)   vce(robust) posttrend  replace corr(ar 14)


***********************High  

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if risk==2, single  trperiod(0)   vce(robust) posttrend  replace corr(ar 14)

***********************Critical+extreme  

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(0) vce(robust)   posttrend  replace corr(ar 14)



****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

***********************Low 
. xtitsa Avg_cases i.calender_week_from_opening if risk==0  , single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==0, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening    , single  trperiod(2) posttrend  replace vce(robust) corr(ar 14)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==0, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==0, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)



***********************Mid  

****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening  if risk==1, single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==1, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 14)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==1, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==1, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)

***********************High  

****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening if risk==2  , single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==2, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 14)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==2, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==2, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)


***********************Critical+extreme  
****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening  if risk==3 , single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 14)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 14)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)



**********************************************************************************Risk levels for B category 

************lG 0
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 4)

***********************Low 
xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if risk==0, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 4)


****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(1) posttrend  replace vce(robust) corr(ar 4)

***********************Low 
xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==0, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 4)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==0, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==0, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)



***********************Mid  
************lG 0
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x0##i.income_median i._x0#i.white_only_percent_cat  i._x0#i.blk_african_amr_percent_cat i._x0#i.other_races_percent_cat  i._x0#i.non_hispanic_latin_percent_cat   i._x0#c.hispanic_latin_percent_cat   i._x0#i.others_ethn_percent_cat i._x0#i.less_20_cat  i._x0#i.age_20_39_cat i._x0#i.age_40_59_cat  i._x0#i.age_60_84_cat i._x0#i.age_over_85_cat if risk==1, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 4)
****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(1) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==1, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 4)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==1, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==1, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)

***********************High  

****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(1) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if risk==2, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 4)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if risk==2, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if risk==2, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)


***********************Critical+extreme  
****************************************************Risk Levels *************lag1
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(1) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 4)


xtitsa Avg_cases i.calender_week_from_opening   i._x2##i.income_median i._x2#i.white_only_percent_cat  i._x2#i.blk_african_amr_percent_cat i._x2#i.other_races_percent_cat  i._x2#i.non_hispanic_latin_percent_cat   i._x2#c.hispanic_latin_percent_cat   i._x2#i.others_ethn_percent_cat i._x2#i.less_20_cat  i._x2#i.age_20_39_cat i._x2#i.age_40_59_cat  i._x2#i.age_60_84_cat i._x2#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(3) posttrend  replace vce(robust) corr(ar 4)

xtitsa Avg_cases i.calender_week_from_opening   i._x3##i.income_median i._x3#i.white_only_percent_cat  i._x3#i.blk_african_amr_percent_cat i._x3#i.other_races_percent_cat  i._x3#i.non_hispanic_latin_percent_cat   i._x3#c.hispanic_latin_percent_cat   i._x3#i.others_ethn_percent_cat i._x3#i.less_20_cat  i._x3#i.age_20_39_cat i._x3#i.age_40_59_cat  i._x3#i.age_60_84_cat i._x3#i.age_over_85_cat if (risk==3|risk==5), single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)


********************************************************************ITSA Command For risk levels 


****************************************A & Bcategory 
ssc install itsa





*************************************************************************Low ,mid,high,extreme
************lag 0
. itsa Avg_cases    , single  trperiod(0) posttrend  replace  


************lag 1 


. itsa Avg_cases    , single  trperiod(1) posttrend  replace  


********lag2


. itsa Avg_cases    , single  trperiod(2) posttrend  replace  

***********8Lag3

. itsa Avg_cases    , single  trperiod(3) posttrend  replace  




***************************************************************************************Risk Levels without Demographic***********************************************

****************************************A category 
****************************************************Risk Levels  lag0
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 14)



*************************************************************************Low 
************lag 0
xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 14)


************lag 1 


xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)


********lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3

xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)



***********************Mid  


*********lag 0 
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 14)

** *************lag1

xtitsa Avg_cases i.calender_week_from_opening   if risk==1, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

****************lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==1, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

**********Lag3

xtitsa Avg_cases i.calender_week_from_opening   if risk==1, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)

***********************High  
*************lag 0
xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 14)

 *************lag1

xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********8Lag3

xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)


***********************Critical+extreme  

*********************lag 0 
xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 14)


*************lag1

xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 14)


xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 14)

***********Lag3

xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 14)



**********************************************************************************Risk levels for B category 



*************************************************************************Low 
************lag 0
xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 4)


************lag 1 


xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)


********lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3

xtitsa Avg_cases i.calender_week_from_opening    if risk==0, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)



***********************Mid  


*********lag 0 
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(0) posttrend  replace vce(robust) corr(ar 4)

** *************lag1

xtitsa Avg_cases i.calender_week_from_opening   if risk==1, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

****************lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==1, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

**********Lag3

xtitsa Avg_cases i.calender_week_from_opening   if risk==1, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)

***********************High  
*************lag 0
xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 4)

 *************lag1

xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2


xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********8Lag3

xtitsa Avg_cases i.calender_week_from_opening    if risk==2, single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)


***********************Critical+extreme  

*********************lag 0 
xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(0)  vce(robust)  posttrend  replace corr(ar 4)


*************lag1

xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

********lag2
. xtitsa Avg_cases i.calender_week_from_opening   , single  trperiod(2) posttrend  replace vce(robust) corr(ar 4)


xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(2)  vce(robust)  posttrend  replace corr(ar 4)

***********Lag3

xtitsa Avg_cases i.calender_week_from_opening    if (risk==3|risk==5), single  trperiod(3)  vce(robust)  posttrend  replace corr(ar 4)


***************************************************************************************Urban/Rural interrupted 
. g indicator=1 if ur==1| ur==2|ur==3


. replace indicator=2 if ur==4| ur==5|ur==6

************
**Urban 
keep if indicator==1
**Rural 
keep if indicator==2
****************************************************
. xtitsa Avg_cases i.calender_week_from_opening   if category=="A" , single  trperiod(1) posttrend  replace vce(robust) corr(ar 14)

***********************Category A 
xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if category=="A", single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 14)



******************Category Bcategory
. xtitsa Avg_cases i.calender_week_from_opening   if (category=="B")  , single  trperiod(1) posttrend  replace vce(robust) corr(ar 2)

***********************Category B
xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if category=="B", single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 4)

****************************************************
. xtitsa Avg_cases i.calender_week_from_opening   if category=="C" , single  trperiod(1) posttrend  replace vce(robust) corr(ar 5)

***********************Category C 
xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if category=="C", single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 5)



******************Category Bcategory
. xtitsa Avg_cases i.calender_week_from_opening   if (category=="D")  , single  trperiod(1) posttrend  replace vce(robust) corr(ar 2)

***********************Category D
xtitsa Avg_cases i.calender_week_from_opening   i._x1##i.income_median i._x1#i.white_only_percent_cat  i._x1#i.blk_african_amr_percent_cat i._x1#i.other_races_percent_cat  i._x1#i.non_hispanic_latin_percent_cat   i._x1#c.hispanic_latin_percent_cat   i._x1#i.others_ethn_percent_cat i._x1#i.less_20_cat  i._x1#i.age_20_39_cat i._x1#i.age_40_59_cat  i._x1#i.age_60_84_cat i._x1#i.age_over_85_cat if category=="D", single  trperiod(1)  vce(robust)  posttrend  replace corr(ar 2)


****************************************************************ITSA with UR_7_15

. g indicator=1 if ur==1| ur==2|ur==3


. replace indicator=2 if ur==4| ur==5|ur==6

************
**Urban 
keep if indicator==1
**Rural 
keep if indicator==2
 collapse (mean)  Avg_cases=cases_per_100K, by(week_from_opening_7_5_2_fix  category )
 
 .  g weeks= week_from_opening_7_5_2_fix-5
 drop if weeks==-5
 drop if weeks==.

 encode category, generate(category_)


g cat_id=0
replace cat_id=1 if category=="A"
replace cat_id=2 if category=="B"
replace cat_id=3 if category=="C"
replace cat_id=4 if category=="D"

tsset cat_id week_from_opening_7_5_2_fix

itsa Avg_cases  , single  trperiod(1)  treatid(4) posttrend   replace

itsa Avg_cases  , single  trperiod(2)  treatid(4) posttrend   replace

itsa Avg_cases  , single  trperiod(3)  treatid(4) posttrend   replace

itsa Avg_cases  , single  trperiod(4)  treatid(4) posttrend   replace





****************************************************************Explain table summurize all variable in each category
ssc install estout

eststo A: estpost summarize Avg_cases   less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent  if category =="A"
eststo B: estpost summarize Avg_cases  VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent  if category =="B"
eststo C: estpost summarize Avg_cases  VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent if category =="C"
eststo D: estpost summarize Avg_cases  VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent if category =="D"

esttab A B C D using table_final2.rtf,  replace cell("mean(fmt(2)) sd(fmt(2))") nonumber nostar mtitle("Recommended-Mandate" "Non-Mandate" "Mandate-Recommended" "Non-Recommended") refcat( less_20 "Age:" hispanic_latin_percent "Ethnicity:" white_only_percent "Race:" , nolabel) coeflabel( Avg_cases "Cases per 100k" VarG2 "Median Income (dollars)" less_20 "Age<20" age_20_39 "Age_20-39" age_40_59 "Age_40-59" age_60_84 "Age_60-84" age_over_85 "Age>85"  hispanic_latin_percent "Hispanic or Latino" non_hispanic_latin_percent "Non Hispanic or Latino" others_ethnicity_percent "Other Ethnicity" white_only_percent "White Only" blk_african_amr_percent "Black or African American" other_races_percent "Other Races"  income_median "Income") title(Table 1. Descriptive statistics of covariates included in the regression models)

**************************************************table Urban/Rural 




eststo urban: estpost summarize Avg_cases   VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent  if indicator ==1

eststo rural: estpost summarize Avg_cases   VarG2 less_20 age_20_39 age_40_59 age_60_84 age_over_85 hispanic_latin_percent non_hispanic_latin_percent  others_ethnicity_percent white_only_percent blk_african_amr_percent other_races_percent  if indicator ==2


esttab urban rural using table_final2.rtf,  replace cell("mean(fmt(2)) sd(fmt(2))") nonumber nostar mtitle("Urban" "Rural") refcat( less_20 "Age:" hispanic_latin_percent "Ethnicity:" white_only_percent "Race:" , nolabel) coeflabel( Avg_cases "Cases per 100k" VarG2 "Median Income (dollars)" less_20 "Age<20" age_20_39 "Age_20-39" age_40_59 "Age_40-59" age_60_84 "Age_60-84" age_over_85 "Age>85"  hispanic_latin_percent "Hispanic or Latino" non_hispanic_latin_percent "Non Hispanic or Latino" others_ethnicity_percent "Other Ethnicity" white_only_percent "White Only" blk_african_amr_percent "Black or African American" other_races_percent "Other Races"  income_median "Income") title(Table 1. Descriptive statistics of covariates included in the regression models)


*************************************************************Unadjusted Means all categories 

  mean cases_per_100K if category=="A" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_A

  mean cases_per_100K if category=="D" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_D
 
   mean cases_per_100K if category=="B" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_B

   mean cases_per_100K if category=="C" &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_C
 
 coefplot  (cat_A,recast(connected)  label(Recommended-Mandate) mlcolor(black) mcolor(red ) msize(7-pt) msymbol(D ) lcolor(black))  (cat_B,recast(connected)  label(No restriction-Mandate) mlcolor(black) mcolor(blue ) msize(7-pt) msymbol(S ) lcolor(black))  (cat_D,recast(connected)  label(No restriction-Recommended) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(T ) lcolor(black)) ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean COVID-19 Incidence Rate per 100,000 Residents",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean COVID-19 Incidence Rate per 100,000 Residents ",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(gr2)
 
  coefplot   (cat_D,recast(connected)  label(No restriction-Recommended) mlcolor(black) mcolor(blue ) msize(7-pt) msymbol(S ) lcolor(black))  ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (No restriction-Recommended)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(gr22)
  
   coefplot   (cat_B,recast(connected)  label(No restriction-Mandate) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(T ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (No restriction-Mandate)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(gr333)
   
    coefplot   (cat_C,recast(connected)  label(Mandate-Recommended) mlcolor(black) mcolor(green ) msize(7-pt) msymbol(O ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Mandate-Recommended)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(gr44)
	
	gr combine "gr111" "gr22" "gr333" "gr44" ,imargin(1 2 2 1) graphregion(margin(l=2 r=1))


	
 ***********************************************************************************Unadjusted Risk Levels
 
*************************************************************Unadjusted Means all categories 

  mean cases_per_100K if risk==0 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_low

 coefplot  (cat_low,recast(connected)  label(Low Risk) mlcolor(black) mcolor(green ) msize(7-pt) msymbol(D ) lcolor(black))    ,     graphregion(fcolor(gs15))  ylabel(0(10)70) yscale(range(0(10)70)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Low Risk)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(low2)

  mean cases_per_100K if risk==1 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_mid
 
  coefplot   (cat_mid,recast(connected)  label(Medium Risk) mlcolor(black) mcolor(sandb ) msize(7-pt) msymbol(S ) lcolor(black))    ,     graphregion(fcolor(gs15))  ylabel(0(10)70) yscale(range(0(10)70)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Medium Risk)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(mid2)
  
  
   mean cases_per_100K if risk==2 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_high

coefplot   (cat_high,recast(connected)  label(High Risk) mlcolor(black) mcolor(orange ) msize(7-pt) msymbol(T ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)70) yscale(range(0(10)70)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (High Risk)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(high2)
 

   mean cases_per_100K if (risk==3|risk==5) &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store cat_extreme
 
 coefplot (cat_low,recast(connected)  label(low) mlcolor(black) mcolor(green ) msize(7-pt) msymbol(O ) lcolor(black))   (cat_mid,recast(connected)  label(Medium) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(O ) lcolor(black)) (cat_high,recast(connected)  label(High) mlcolor(black) mcolor(red ) msize(7-pt) msymbol(O ) lcolor(black))    (cat_extreme,recast(connected)  label(Critical&Extreme Risk) mlcolor(black) mcolor(maroon ) msize(7-pt) msymbol(O ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)70) yscale(range(0(10)70)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Critical&Extreme Risk)",size(2.5)) msymbol(d) noci legend(size(vsmall)) saving(critical2)
 
 
 gr combine "gr2" "gr1111" "critical2" ,imargin(1 2 2 1) graphregion(margin(l=2 r=1))
 
 	gr combine "low2" "gr1111" "critical2" ,imargin(1 2 2 1) graphregion(margin(l=2 r=1))
***********************************************************************************************************Urban/Rural unadjusted mean 

 ***********Urban 
  mean cases_per_100K if category=="A" & indicator==1&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ur_A

  mean cases_per_100K if category=="D" & indicator==1&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ur_D
 
   mean cases_per_100K if category=="B"& indicator==1 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ur_B

   mean cases_per_100K if category=="C" & indicator==1&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ur_C
 
  ***********Rural 
  mean cases_per_100K if category=="A" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_A

  mean cases_per_100K if category=="D" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_D
 
   mean cases_per_100K if category=="B"& indicator==2 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_B

   mean cases_per_100K if category=="C" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_C


 coefplot  (ur_A,recast(connected)  label(Urban) mlcolor(black) mcolor(red ) msize(7-pt) msymbol(D ) lcolor(black)) (ru_A,recast(connected)  label(Rural) mlcolor(black) mcolor(midblue ) msize(7-pt) msymbol(D ) lcolor(black))  ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Recommended-Mandate)",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr1)
 
  coefplot   (ur_D,recast(connected)  label(Urban) mlcolor(black) mcolor(blue ) msize(7-pt) msymbol(S ) lcolor(black))  (ru_D,recast(connected)  label(Rural) mlcolor(black) mcolor(orange ) msize(7-pt) msymbol(S ) lcolor(black)) ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k(No restriction-Recommended)",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr77777)
  
   coefplot   (ur_B,recast(connected)  label(Urban) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(T ) lcolor(black)) (ru_B,recast(connected)  label(Rural) mlcolor(black) mcolor(ebblue ) msize(7-pt) msymbol(T ) lcolor(black))  ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (No restriction-Mandate)",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr3)
   
    coefplot   (ur_C,recast(connected)  label(Urban) mlcolor(black) mcolor(green ) msize(7-pt) msymbol(O ) lcolor(black))  (ru_C,recast(connected)  label(Rural) mlcolor(black) mcolor(gold ) msize(7-pt) msymbol(O ) lcolor(black)) ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Mandate-Recommended)",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr4)
	
	gr combine "gr1" "gr77777" "gr3" "gr4" ,imargin(1 2 2 1) graphregion(margin(l=0 r=0))
	
	
 ***********Rural 
  mean cases_per_100K if category=="A" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_A

  mean cases_per_100K if category=="D" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_D
 
   mean cases_per_100K if category=="B"& indicator==2 &week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_B

   mean cases_per_100K if category=="C" & indicator==2&week_from_opening_7_5_2_fix>0&week_from_opening_7_5_2_fix<=17, over(week_from_opening_7_5_2_fix)
estimates store ru_C
 
 coefplot  (ru_A,recast(connected)  label(Recommended-Mandate) mlcolor(black) mcolor(red ) msize(7-pt) msymbol(D ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Recommended-Mandate)-Rural",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr11)
 
  coefplot   (ru_D,recast(connected)  label(No restriction-Recommended) mlcolor(black) mcolor(blue ) msize(7-pt) msymbol(S ) lcolor(black))  ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k(No restriction-Recommended)-Rural",size(2.29)) msymbol(d) noci legend(size(vsmall)) saving(gr12)
  
   coefplot   (ru_B,recast(connected)  label(No restriction-Mandate) mlcolor(black) mcolor(yellow ) msize(7-pt) msymbol(T ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical ytitle("Mean of cases  per100k",size(small)) xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (No restriction-Mandate)-Rural",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr13)
   
    coefplot   (ru_C,recast(connected)  label(Mandate-Recommended) mlcolor(black) mcolor(green ) msize(7-pt) msymbol(O ) lcolor(black))   ,     graphregion(fcolor(gs15))  ylabel(0(10)50) yscale(range(0(10)50)) vertical  xtitle("Weeks",size(small)) ylabel(,labsize(small)) xline(5, lcolor(red) lwidth(thin)) coeflabels(c.cases_per_100K@1.week_from_opening_7_5_2_fix="-4" c.cases_per_100K@2.week_from_opening_7_5_2_fix="-3 "  c.cases_per_100K@3.week_from_opening_7_5_2_fix="-2 "   c.cases_per_100K@4.week_from_opening_7_5_2_fix="-1 "  c.cases_per_100K@5.week_from_opening_7_5_2_fix="0"  c.cases_per_100K@6.week_from_opening_7_5_2_fix="1 "   c.cases_per_100K@7.week_from_opening_7_5_2_fix=" 2" c.cases_per_100K@8.week_from_opening_7_5_2_fix=" 3"  c.cases_per_100K@9.week_from_opening_7_5_2_fix="4"  c.cases_per_100K@10.week_from_opening_7_5_2_fix=" 5" c.cases_per_100K@11.week_from_opening_7_5_2_fix="6 " c.cases_per_100K@12.week_from_opening_7_5_2_fix="7 "  c.cases_per_100K@13.week_from_opening_7_5_2_fix="8" c.cases_per_100K@14.week_from_opening_7_5_2_fix="9" c.cases_per_100K@15.week_from_opening_7_5_2_fix="10" c.cases_per_100K@16.week_from_opening_7_5_2_fix="11" c.cases_per_100K@17.week_from_opening_7_5_2_fix="12"   ,angle(45) labsize(small)) title ("Unadjusted Mean of Covid-19 cases per 100k (Mandate-Recommended)-Rural",size(2.3)) msymbol(d) noci legend(size(vsmall)) saving(gr14)
	
	gr combine "gr11" "gr12" "gr13" "gr14" ,imargin(1 2 2 1) graphregion(margin(l=0 r=0))
